<%@page contentType="text/html" pageEncoding="UTF-8"%><%
String[] cities = {
    "Bandung, Indonesia",
    "Jakarta, Indonesia",
    "Jambi, Indonesia",
    "Amsterdam, Holland",
    "Reykjavik, Island"
};
String q = request.getParameter("q");
if (q != null) {
    if (q.length() == 0) {
        out.print("");
    } else {
        String retval = "";
        for (int i = 0; i < cities.length; i++) {
            if (cities[i].length() > q.length()) {
                if (q.equalsIgnoreCase(cities[i].substring(0,q.length()))) {
                    retval += cities[i]+"$";
                }
            } else if (cities[i].length() == q.length()) {
                if (q.equalsIgnoreCase(cities[i])) {
                    retval += cities[i]+"$";
                }
            }
        }
        out.print(retval);
    }
}
%>